package Skill

import (
	"../ProtoGo"
	"../Robot"
	"github.com/golang/protobuf/proto"
)

var command = Cmd.Command_SCENE_USER_SKILL_PROTOCMD.Enum()

func RegisterSkillHandler(r *Robot.Robot) {
	r.RobotLog("注册技能模块")
	//r.Handler.SetModuleBegin()

	pp := Cmd.SkillParam_SKILLPARAM_SKILLUPDATE.Enum()
	r.Handler.RegisterHandle(byte(*command), byte(*pp), handleSkillUpdate)
}

func handleSkillUpdate(xcmd *Robot.XCommand, robot *Robot.Robot) {
	response := &Cmd.SkillUpdate{}
	if err := proto.Unmarshal(xcmd.Probuf, response); err != nil {
		robot.RobotErr("序列化SkillUpdate")
	} else {
		robot.RobotLog("接收协议SkillUpdate %s", response.String())
	}
}
